package com.blog;

import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;

public class day06StringRegex {

	public static void main(String[] args) {
		/**
		 * 检验以%结尾
		 */
		String s = "10%";
		String x = "12.3";
		boolean ss = Pattern.matches("^(100|[1-9]\\d|\\d)(.\\d{1,2})?%$", s);
		boolean xx = Pattern.matches("^(100|[1-9]\\d|\\d)(.\\d{1,2})?%$", x);
		
		System.out.println(ss); // true		
		System.out.println(xx); // false		
		/**
		 * spf1右边用0补全至6位
		 */
		String spfl = "9090";
		spfl = StringUtils.rightPad(spfl, 6, "0");
		// 结果909000
	}

}
